import Vue from 'vue'
import Router from 'vue-router'

const index = resolve => require(['../pages/index/index'], resolve)
const login = resolve => require(['../pages/admin/login'], resolve)
const search = resolve => require(['../pages/search/search'], resolve)

const originDataRoot = resolve => require(['../pages/originData/root'], resolve)
const originData = resolve => require(['../pages/originData/index'], resolve)
const probeData = resolve => require(['../pages/originData/probeData'], resolve)

const placeRoot = resolve => require(['../pages/place/root'], resolve)
const placeManage = resolve => require(['../pages/place/index'], resolve)
const diviceManage = resolve => require(['../pages/place/diviceManage'], resolve)

const noPage = resolve => require(['../pages/noPage'], resolve)

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: index,
      meta: {
        adminAuth: true
      },
      name: 'index'
    },
    {
      path: '/search/:info',
      component: search,
      meta: {
        adminAuth: true
      },
      name: 'search'
    },
    {
      path: '/place',
      component: placeRoot,
      children: [
        {
          path: 'placeManage',
          component: placeManage,
          meta: {
            adminAuth: true
          },
          name: 'placeManage'
        },
        {
          path: 'diviceManage',
          component: diviceManage,
          meta: {
            adminAuth: true
          },
          name: 'diviceManage'
        }
      ]
    },
    {
      path: '/originData',
      component: originDataRoot,
      children: [
        {
          path: 'index',
          component: originData,
          meta: {
            adminAuth: true
          },
          name: 'originData'
        },
        {
          path: 'probeData',
          component: probeData,
          meta: {
            adminAuth: true
          },
          name: 'probeData'
        }
      ]
    },
    {
      path: '/login',
      component: login,
      name: 'login'
    },
    {
      path: '*',
      component: noPage
    }
  ]
})
